<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">
    <link rel="import" href="indexs.html" id="page1">

    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<script type="text/javascript">
    document.write(page1.import.body.innerHTML);
</script>
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this" id="userFriend">用户</li>
            <li id="coachFriend">教练</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show" id="showUserFriend">

                <!--<div class="layui-row layui-col-space15">
                    <div class="layui-col-md8" style="">
                        <div class="layui-card">
                            <div class="layui-card-body" style="font-size: 20px;margin-top: 10px">
                                <img src="image/71843cbde75bb01b4290011d457552fd.jpg" class="layui-nav-img " style="margin-top: 20px; width: 60px; height: 56px;">
                                <label>昵称：</label><br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>签名：</label>
                                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" style="float: right;">取消关注</button>
                            </div>
                        </div>
                    </div>
                </div>-->

            </div>
            <div class="layui-tab-item" id="showCoachFriend">

                <!--<div class="layui-row layui-col-space15">
                    <div class="layui-col-md8" style="">
                        <div class="layui-card">
                            <div class="layui-card-body" style="font-size: 20px;margin-top: 10px">
                                <img src="image/71843cbde75bb01b4290011d457552fd.jpg" class="layui-nav-img " style="margin-top: 20px; width: 60px; height: 56px;">
                                <label>昵称：</label><br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>签名：</label>
                                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" style="float: right;">取消关注</button>
                            </div>
                        </div>
                    </div>
                </div>-->

            </div>
        </div>
    </div>

</div>
<script src="layui/layui.js" charset="utf-8"></script>
<script src="js/jquery.min.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    $(document).ready(function () {
            showUser();
        $("#userFriend").click(function () {
            showUser();
        });

        $("#coachFriend").click(function () {
            showCoach();
        });
    })


function showUser(){
     $.ajax({
        url:"attention/findEachOtherAttention",
        data:{
            page:1,
            userid1:1,
            usertype1:0
        },
        success:function (data) {
            var content = "";
            for (var i = 0; i < data.eachOtherAttentionDTOS.length; i++) {
                var po = data.eachOtherAttentionDTOS[i];
                if(po.ttrainers == null){
                for (var j = 0; j < po.tstudents.length; j++) {
                    var jo = po.tstudents[j];
                    if(po.tstudents[j].sId != 1){
                content += '<div class="layui-row layui-col-space15">\n' +
                    '                    <div class="layui-col-md8" style="">\n' +
                    '                        <div class="layui-card">\n' +
                    '                            <div class="layui-card-body" style="font-size: 20px;margin-top: 10px">\n' +
                    '                                <img src="image/71843cbde75bb01b4290011d457552fd.jpg" class="layui-nav-img " style="margin-top: 20px; width: 60px; height: 56px;">\n' +
                    '                                <label>昵称：' + jo.sName + '</label><br>\n' +
                    '                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>签名：' + jo.sAddress + '</label>\n' +
                    '                                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" style="float: right;"onclick="cancelConcern('+jo.sId+','+0+')">取消关注</button>\n' +
                    '                            </div>\n' +
                    '                        </div>\n' +
                    '                    </div>\n' +
                    '                </div>'
                    }
                }
                }
            }
            $("#showUserFriend").html(content);
        }
    });
}


    function showCoach() {
        $.ajax({
            url:"attention/findEachOtherAttention",
            data:{
                page:1,
                userid1:1,
                usertype1:0
            },
            success:function (data) {
                console.info(data);
                var content = "";
                for(var i = 0; i < data.eachOtherAttentionDTOS.length; i++){
                    var po = data.eachOtherAttentionDTOS[i];
                    console.info(po);
                    if(po.tstudents == null){
                    for(var j = 0; j < po.ttrainers.length; j++){
                        var jo = po.ttrainers[j];
                        content +='<div class="layui-row layui-col-space15">\n' +
                            '                    <div class="layui-col-md8" style="">\n' +
                            '                        <div class="layui-card">\n' +
                            '                            <div class="layui-card-body" style="font-size: 20px;margin-top: 10px">\n' +
                            '                                <img src="image/71843cbde75bb01b4290011d457552fd.jpg" class="layui-nav-img " style="margin-top: 20px; width: 60px; height: 56px;">\n' +
                            '                                <label>昵称：'+jo.tName+'</label><br>\n' +
                            '                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label>签名：'+jo.tIntroduction+'</label>\n' +
                            '                                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" style="float: right;" onclick="cancelConcern('+jo.tId+','+1+')">取消关注</button>\n' +
                            '                            </div>\n' +
                            '                        </div>\n' +
                            '                    </div>\n' +
                            '                </div>'
                    }
                    }
                }
                $("#showCoachFriend").html(content);
            }
        })
    }
    function cancelConcern(userid2,usertype2) {
        $.ajax({
            url:"attention/delOneAttention",
            data:{
                userid1:1,
                usertype1:0,
                "userid2":userid2,
                "usertype2":usertype2
            },
            success:function (data) {
                alert("取消成功")
                location.reload();
            }
        })
    }

</script>

</body>
</html>